<template>
  <div class="loading">
    <div class="loading-content">
      <p class="desc" v-if="title">{{ title }}</p>
      <i class="iconfont icon-loading"></i>
    </div>
  </div>
</template>
<script lang="ts">
export default {
  name: 'loading'
}
</script>
<script lang="ts" setup>
import { ref } from 'vue'
interface Props {
  title?: string

}

const props = withDefaults(defineProps<Props>(),{
  title: ''
})

const title = ref('')
const setTitle = (t: string) => {
  title.value = t
}
defineExpose({
  title,
  setTitle
})
</script>
<style>
._app_relative{
  position: relative!important;
  pointer-events: none;
}
@keyframes loading-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
<style lang="scss" scoped>

.loading {
  position: absolute;
  background: rgba(255,255,255,.8);
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 2000;
  .loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    .desc {
      line-height: 20px;
      font-size: 12px;
      color: #333;
    }
    .icon-loading{
      color: #2693ff;
      display: flex;
      font-size: 2em;
      animation: loading-rotate 3s linear infinite;
    }
  }
}
</style>
